package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.event.AdministratorEvent;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.model.impl.ReportedInfoModel;
import com.clas.liu.myapplication.presenter.i.IReportedInfoPresenter;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;
import com.clas.liu.myapplication.view.activity.impl.ReportedInfoActivity;

/**
 * Created by liu on 2019/5/27.
 */

public class ReportedInfoPresenter extends BasePresenter<ReportedInfoActivity,ReportedInfoModel> implements IReportedInfoPresenter {
    public ReportedInfoPresenter(ReportedInfoActivity view) {
        super(view);
    }

    @Override
    public void getInfo(int page_no, int page_size) {
        mModel.getInfo(page_no,page_size);
    }

    @Override
    public void deleteInfo(int info_id, int id) {
        mModel.deleteInfo(info_id,id);
    }

    @Override
    public void cancel(int id) {
        mModel.cancel(id);
    }

    @Override
    protected ReportedInfoModel getModel(Handler handler) {
        return new ReportedInfoModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case AdministratorEvent.GET_REPORTED_INFO_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.GET_REPORTED_INFO_OK:
                mView.dataReturn(((AdministratorEvent)msg.obj).getReportedInfoRoot().getData());
                break;
            case AdministratorEvent.DELETE_REPORTED_INFO_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.DELETE_REPORTED_INFO_OK:
                mView.deleteReturn();
                break;
            case AdministratorEvent.CANCEL_INFO_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.CANCEL_INFO_OK:
                mView.cancelReturn();
                break;
        }
    }
}
